<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>用户列表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <script type="text/javascript" src="${baseurl}statics/assets/js/jquery-1.10.2.min.js"></script>

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript">
        $(function() {
            $.ajax({
                url: "${baseurl}user/selectKey",
                type: "post",
                dataType:"json",
                success: function (json) {
                    if(json.userKey==1){
                        $("#checkAll").hide();
                        $("#noCheckAll").show();
                    }else{
                        $("#noCheckAll").hide();
                        $("#checkAll").show();
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        });
    </script>


</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">系统管理</a>
        </li>

        <li>
            <a href="${baseurl}user/findAllUser?roleId=1&adminId=1">用户管理</a>
        </li>
        <li class="active">用户列表</li>
    </ul><!-- .breadcrumb -->


</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">用户列表</h3>
                    <div class="table-header">
                        用户列表信息
                    </div>
                    <div class="table-responsive clearfix">
                        <div style="width: 25%" class="system_top_l clearfix">
                            <form class="form-search" action="${baseurl}user/findAllUser?roleId=${sysUserManage.roleId}&adminId=${sysUserManage.id}"
                                  method="post">
                                <div class="row" style="margin-top: 20px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control search-query" name="keywords"
                                                   value="${keywords}"
                                                   placeholder="请输入手机号"/>
                                            <span class="input-group-btn">
                                                <button type="submit" class="btn btn-purple btn-sm">
                                                    搜索
                                                    <i class="icon-search icon-on-right bigger-110"></i>
                                                </button>
                                            </span>

                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- 时间筛选 -->


<%--

                        <div  class="open1">

                        </div>


                        <div class="open1">

                        </div>
--%>



                        <div class="system_top_r learfix">
                            <div style="margin-top: 20px;">
                                <shiro:hasPermission name="user:add">
                                    <div id="inPermission">
                                        <a class="btn btn-purple btn-sm" href="${baseurl}user/addUser"
                                           style="margin-left: 20px;">添加</a>
                                    </div>
                                </shiro:hasPermission>

                        <%--<div style="float: left;margin-top: 20px;">--%>
                            <%--<shiro:hasPermission name="user:add">--%>
                                <%--<div id="inPermission">--%>
                                    <%--<a class="btn btn-purple btn-sm" href="${baseurl}user/addUser"--%>
                                       <%--style="margin-left: 20px;">添加</a>--%>
                                <%--</div>--%>
                            <%--</shiro:hasPermission>--%>
                        </div>

                        <!--导入 -->
<%--                        <div style="float: left;margin-top: 20px;">
                            <div id="">
                                <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: 0px;left: 20px;" id="e2" value="导入" onclick="xuanze.click()"/>
                                <input type="file" id="xuanze" name="upfile"  style="float: left;display: none;">
                            </div>
                            <!--导入 -->
                            <%--                        <div style="float: left;margin-top: 20px;">
                                                        <div id="">
                                                            <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: 0px;left: 20px;" id="e2" value="导入" onclick="xuanze.click()"/>
                                                            <input type="file" id="xuanze" name="upfile"  style="float: left;display: none;">
                                                        </div>
                                                    </div>--%>
                            <!--导出 -->
                            <div style="float: left;margin-top: 20px;">
                                <div >
                                    <input type="button" class="btn btn-purple btn-sm" style="position: relative;bottom: 0px;" id="e3" value="导出"
                                           onclick="window.location.href='${baseurl}fileController/outExcel'"/>
                                </div>
                            </div>
                            <shiro:hasPermission name="user:checked">
                            <div class="open1" style="float: left;margin-top: 20px;margin-left: 20px;">
                                <span>
                                     <!--一键审核按钮-->
                                    <input type="button" id="checkAll" value="一键审核" style="background-color: #9585bf !important;color: #fff;height: 36px;border: none;"/>
                        <!--取消一键审核按钮-->
                                    <input type="button" id="noCheckAll" value="取消一键审核" style="display: none;background-color: #9585bf !important;color: #fff;height: 36px;border: none;"/>
                                </span>
                            </div>
                            </shiro:hasPermission>
                        </div>

                        <input type="hidden" id="adminName" value="${sysUserManage.userName}">
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="margin-top: 20px; table-layout:fixed;">
                            <thead>
                            <tr>
                                <th class="center" style="width: 5%;">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center;width: 10%">Id</th>
                                <th style="text-align: center;width: 8%">用户名称</th>
                                <th style="text-align: center;width: 8%">手机号码</th>
                                <th style="text-align: center;width: 5%">岗位</th>
                                <th style="text-align: center;width: 5%">QQ</th>
                                <th style="text-align: center;width: 10%">企业名称</th>
                                <th style="text-align: center;width: 15%">企业地址</th>
                                <th style="text-align: center;width: 10%">仓库地址</th>
                                <th style="text-align: center;width: 10%">注册时间</th>
                                <th style="text-align: center;width: 5%">来源</th>
                                <th style="text-align: center;width: 5%">审批状态</th>
                                <th style="text-align: center;width: 5%">业务状态</th>
                                <th style="text-align: center;width: 5%">
                                    业务操作
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.records}" var="user">
                                <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>
                                    <td style="text-align: center">${user.id}</td>
                                    <td style="text-align: center">
                                        <a  href="${baseurl}user/details?userId=${user.id}"
                                           target="iframe_bt">${user.userName}</a>
                                    </td>
                                    <td style="text-align: center">${user.userPhone}</td>
                                    <td style="text-align: center">${user.job}</td>
                                    <td style="text-align: center">${user.qq}</td>
                                    <td style="text-align: center">${user.companyName}</td>
                                    <td style="text-align: center;">${user.companyAddress}</td>
                                    <td style="text-align: center;">${user.storageAddress}</td>
                                    <td style="text-align: center">${fn:substring(user.createTime,0,19)}</td>
                                    <td style="text-align: center">
                                        <c:if test="${user.source==0}">
                                            后台
                                        </c:if>
                                        <c:if test="${user.source==1}">
                                            PC端
                                        </c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${counts == 0}">
                                            <c:if test="${user.status == 1}">审核中</c:if>
                                            <c:if test="${user.status == 2}"><span
                                                    style="color: green;font-weight: bold">审核通过</span></c:if>
                                            <c:if test="${user.status == 3}"><span
                                                    style="color: red;font-weight: bold">审核不通过</span>(请修改)</c:if>
                                        </c:if>
                                        <c:if test="${counts == 1}">
                                                <c:if test="${user.status == 2}"> <span
                                                        style="color: green;font-weight: bold">审核通过</span> </c:if>
                                                <c:if test="${user.status == 1}">
                                                    <a href="javascript:onclick = examine('${user.id}',2);">通过</a>
                                                    <a href="javascript:onclick = examine('${user.id}',3);">不通过</a>
                                                </c:if>
                                                <c:if test="${user.status == 3}"><span
                                                        style="color: red;font-weight: bold">审核不通过</span></c:if>
                                        </c:if>
                                    </td>
                                    <td>
                                        <c:if test="${user.valid == 0}">
                                            禁用
                                        </c:if>
                                        <c:if test="${user.valid == 1}">
                                            启用
                                        </c:if>
                                        <c:if test="${user.valid == 2}">
                                            启用
                                        </c:if>
                                    </td>
                                    <td>
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                            <shiro:hasPermission name="user:find">
                                                <a class="blue" href="${baseurl}user/details?userId=${user.id}"
                                                   target="iframe_bt">
                                                    详情
                                                </a>
                                            </shiro:hasPermission>
                                            <!--审核不通过的情况下要进行修改-->
                                            <shiro:hasPermission name="user:update">
                                                <c:if test="${user.status == 3 && user.valid != 0}">
                                                    <a class="green" href="${baseurl}user/toUpdate?userId=${user.id}" target="iframe_bt">
                                                       修改
                                                    </a>
                                                </c:if>
                                            </shiro:hasPermission>
                                            <%--<shiro:hasPermission name="user:delete">--%>
                                                <%--<a class="red" href="javascript:onclick = del(${user.id});">--%>
                                                    <%--<i class="icon-trash bigger-130"></i>--%>
                                                <%--</a>--%>
                                            <%--</shiro:hasPermission>--%>
                                            <shiro:hasPermission name="user:isenable">
                                                <c:if test="${user.valid == 1 && user.status == 2}" >
                                                    <a href="javascript:onclick = isenable('${user.id}',0);"><span
                                                            style="color: red;font-weight: bold;">禁用</span></a>
                                                </c:if>
                                                <c:if test="${user.valid == 0 && user.status != 1}">
                                                    <a href="javascript:onclick = isenable('${user.id}',1);"><span
                                                            style="color: green;font-weight: bold;">启用</span></a>
                                                </c:if>
                                            </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->
</div>

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
    $(function () {
        /*var table = new TableInit();
        table.Init();
        $("#reportTable").on("load-success.bs.table", function (data) {
            var height = $("body").height();
            $("#iframe", window.parent.document).height(height);
        });*/
        //导入导出
        $("#loadgif").hide();
        $("#xuanze").wrap("<form  id='myupload' action='${baseurl}fileController/inExcel' enctype='multipart/form-data' method='post' ></form>");
        $("#xuanze").change(function () {
            var formData = new FormData($("#myupload")[0]);
            $.ajax({
                url: "${baseurl}fileController/inExcel",
                type: "post",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                beforeSend: function () {
                    $("#loadgif").show();
                },
                processData: false,
                success: function (json) {
                    $("#loadgif").hide();
                    if (json.result == "1") {
                        alert("info"+json.info);
                        location.reload();
                    } else {
                        alert("message"+json.message);
                        location.reload();
                    }
                },
                error: function (json) {
                    $("#loadgif").hide();
                    alert("导入数据失败");
                    location.reload();
                }
            });
        });
    });
    //    删除用户数据
    <%--function del(id) {--%>
        <%--var k = window.confirm("确定是否要删除！");--%>
        <%--if (k) {--%>
            <%--$.ajax({--%>
                <%--url: "${baseurl}user/delete",--%>
                <%--data: {"userId": id},--%>
                <%--type: "post",--%>
                <%--success: function (json) {--%>
                    <%--console.log(json.code);--%>
                    <%--if (json.code == 0) {--%>
                        <%--alert(json.message);--%>
                        <%--location.reload();--%>
                    <%--} else {--%>
                        <%--alert(json.message);--%>
                    <%--}--%>
                <%--},--%>
                <%--error: function (json) {--%>
                    <%--alert("error");--%>
                <%--}--%>
            <%--});--%>
        <%--}--%>
    <%--}--%>

    $('#checkAll').click(function(){
        var r=confirm("确定要一键审核吗?")
        if (r==true){
            $("#checkAll").hide();
            $("#noCheckAll").show();
            $.ajax({
                url: "${baseurl}user/keyPass",
                type: "post",
                dataType:"json",
                success: function (json) {
                    location.reload();
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    });

    $("#noCheckAll").click(function () {
        var r=confirm("确定要取消一键审核吗?")
        if (r==true){
            $("#noCheckAll").hide();
            $("#checkAll").show();
            $.ajax({
                url: "${baseurl}user/noKeyPass",
                type: "post",
                dataType:"json",
                success: function (json) {

                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    });

    <!--启用或禁用-->
    function isenable(id, status) {
        var adminName = $("#adminName").val();
        var k = false;
        if (status === 0) {
            k = window.confirm("确定是否要禁用");
        } else {
            k = window.confirm("确定是否要启用");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}user/isenable",
                data: {"userId": id, "isenable": status, "adminName": adminName},
                type: "post",
                success: function (json) {
                    if (json.code === 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    <!--审核通过或不通过-->
    function examine(id, status) {
        var adminName = $("#adminName").val();
        var k = false;
        if (status == 2) {
            k = window.confirm("确定是否要通过");
        } else {
            k = window.confirm("确定不通过吗?");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}user/examine",
                data: {"userId": id, "examine": status, "adminName": adminName},
                type: "post",
                success: function (json) {
                    console.log(json.code);
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }
</script>
</body>
</html>

